﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Shape.Mvp.Sample.Views
{
	public partial class PositionListDialog : Form, IPositionListView
	{
		public PositionListDialog()
		{
			InitializeComponent();
		}

		private void cmdOk_Click(object sender, EventArgs e)
		{
			if (Accepted != null)
			{
            Accepted(sender, e);

				if (CanClose)
					this.Close();
			}
		}
		public event EventHandler Accepted;

		public event EventHandler Cancelled;

		public event Action ShowPositionList;

		public bool CanClose { get; set; }

		public void ClearPositions()
		{
			cboPositions.Items.Clear();
		}

		public void AddPosition(string key, string name)
		{
			var position = new KeyValuePair<string,string>(key, name);

			cboPositions.Items.Add(position);

			cboPositions.DisplayMember = "Value";
		}

		public string SelectedPosition()
		{
			return ((KeyValuePair<string, string>)cboPositions.SelectedItem).Key;
		}
	}
}
